//
//  ADLocationModel+Map.m
//  ADUserPro
//
//  Created by AnDa-Y on 2020/8/3.
//  Copyright © 2020 AnDa-Y. All rights reserved.
//

#import "ADLocationModel+Map.h"
#import <MAMapKit/MAGeometry.h>

@implementation ADLocationModel (Map)

- (double)distanceTo:(ADLocationModel *)fromLocation
{
    CLLocationCoordinate2D from = CLLocationCoordinate2DMake(self.latitude, self.longitude);
    CLLocationCoordinate2D to = CLLocationCoordinate2DMake(fromLocation.latitude, fromLocation.longitude);
    
    MAMapPoint f = MAMapPointForCoordinate(from);
    MAMapPoint t = MAMapPointForCoordinate(to);
    
    CLLocationDistance distance = MAMetersBetweenMapPoints(f, t);
    return distance;
}
@end
